﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Utility.Domains.Repositories
{
    /// <summary>
    /// 基础仓储接口，提供通过的增删改查
    /// </summary>
    /// <typeparam name="TPO"></typeparam>
    public interface IBaseRepository<TPO> where TPO : class, new()
    {
        /// <summary>
        /// 创建数据库表
        /// </summary>
        void CreateTable();

        /// <summary>
        /// 根据主键获取
        /// </summary>
        /// <param name="key">主键值</param>
        /// <returns></returns>
        TPO GetByKey(object key);

        /// <summary>
        /// 根据主键删除
        /// </summary>
        /// <param name="key">主键值</param>
        /// <returns>受影响的行数</returns>
        int Delete(object key);
        /// <summary>
        /// 批量删除
        /// </summary>
        /// <param name="list">数据集合</param>
        /// <returns></returns>
        int BatchDelete(List<TPO> list);

        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="obj">要更新的对象</param>
        /// <returns>受影响的行数</returns>
        int Update(TPO obj);

        /// <summary>
        /// 插入
        /// </summary>
        /// <param name="obj">要插入的新对象</param>
        /// <returns>新插入的Id值</returns>
        long Insert(TPO obj);

        /// <summary>
        /// 批量插入
        /// </summary>
        /// <param name="obj">要插入的新对象</param>
        /// <returns>受影响的行数</returns>
        int Insert(List<TPO> obj);
    }
}
